import 'package:flutter/material.dart';
import 'package:live_bg_mobile/router_table.dart';

import '../../main.dart';

class NavigatorUtil {
  static NavigatorState? getNavigatorState() {
    return MyApp.navigatorKey.currentState;
  }

  static void pushNamedAndRemoveUntil(String routerName) {
    NavigatorState? navigatorState = getNavigatorState();
    if (navigatorState != null) {
      navigatorState.pushNamedAndRemoveUntil(routerName, (route) => false);
    }
  }

  static void pushNamed(String routerName) {
    NavigatorState? navigatorState = getNavigatorState();
    if (navigatorState != null) {
      navigatorState.pushNamed(routerName);
    }
  }

  static void pushLoginAndRemoveUntil() {
    pushNamedAndRemoveUntil(RouterTable.loginPath);
  }

  static void pushLogin(e) {
    pushNamed(RouterTable.loginPath);
  }

}
